package view;

import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;

import tv_model.Constants;

public class Emulator_tv extends JFrame{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	static tv_model.Tv tv;
	static JTextArea tv_info;
	

	 public Emulator_tv(tv_model.Tv tv) {
		 	Emulator_tv.tv = tv;
	        initUI();
	 }
	 
	 public static void notifyInfo(){
		 tv_info.setText(tv.toString());
	 }
	 
    public final void initUI() {
       
	   JPanel panel = new JPanel();
       getContentPane().add(panel);

       panel.setLayout(null);
  
       //Button + Channel
       JButton plusButton = new JButton("+");
       plusButton.setBounds(10, 10, 80, 30);
       plusButton.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent event) {
        	   	tv.changeChannel(Constants.Operation.PLUS);       	   
          }
       });
       //Button - Channel
       JButton minusButton = new JButton("-");
       minusButton.setBounds(10, 50, 80, 30);
       minusButton.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent event) {
       	   	tv.changeChannel(Constants.Operation.MINUS);
          }
       });
       
       //Tv Information
       tv_info = new JTextArea(tv.toString());
       tv_info.setBounds(100, 5, 480, 120);
       tv_info.setWrapStyleWord(true);
       tv_info.setLineWrap(true);
       
       //Adding to the panel
       panel.add(plusButton);
       panel.add(minusButton);
       panel.add(tv_info);

       setTitle("TV Emulator");
       setSize(600, 300);
       setLocationRelativeTo(null);
       setDefaultCloseOperation(EXIT_ON_CLOSE);
       
    }

}
